package com.atguigu.tingshu.comment.config;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.util.AuthContextHolder;
import com.atguigu.tingshu.common.util.IdWorker;
import com.atguigu.tingshu.model.comment.Comment;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/testText")
public class Test {

    @Autowired
    private TextDetection textDetection;

    @Autowired
    private MongoTemplate mongoTemplate;
    @Autowired
    private IdWorker idWorker;

    @SneakyThrows
    @GetMapping("/addComment")
    public String addComment(){
        for (int i = 0; i < 300; i++) {
            Comment comment = new Comment();
            comment.setId(i+ "");
            comment.setAlbumId(934L);
            comment.setTrackId(36314L);
            comment.setUserId(2L);
            comment.setNickname("userName");
            comment.setAvatarUrl("111");
            comment.setContent("评论" + i);
            comment.setReplyCommentId("0");
            comment.setPraiseCount(0);
            comment.setAlbumCommentScore(10);
            comment.setCreateTime(new Date());
            comment.setIsPraise(false);
            comment.setReplyCommentList(null);
            comment.setParent(null);
            comment.setDeleteMark("1");
            Thread.sleep(1000);
            mongoTemplate.save(comment);
        }
        return "SUCC";
    }

    @SneakyThrows
    @GetMapping
    public Result textTest(){
        JSONObject resultJson = textDetection.greenTextDetection("冰毒");
        String result = (String) resultJson.get("Suggestion");
        System.out.println("result = " + result);
        return Result.ok();
    }


}
